/*
package com.jstide.credit.data.client.jdbc;

import java.io.InputStream;
import java.sql.SQLException;
import java.util.Properties;

import cn.hutool.core.lang.Singleton;
import cn.hutool.core.util.StrUtil;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidDataSourceFactory;
import com.alibaba.druid.pool.DruidPooledConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DBPoolConnection {

    static Logger log = LoggerFactory.getLogger(DBPoolConnection.class);
    private static DBPoolConnection dbPoolConnection = null;
    private static DruidDataSource druidDataSource = null;

    static {
        Properties properties = loadPropertiesFile("db.properties");
        try {
            druidDataSource = (DruidDataSource)DruidDataSourceFactory.createDataSource(properties);
        } catch (Exception e) {
            log.error("获取配置失败");
        }
    }


    public static synchronized DBPoolConnection getInstance(){
        dbPoolConnection  = Singleton.get(DBPoolConnection.class);
        return dbPoolConnection;
    }


    public DruidPooledConnection getConnection() throws SQLException{
        return druidDataSource.getConnection();
    }

    private static Properties loadPropertiesFile(String fullFile) {
        if (StrUtil.isBlank(fullFile)){
            throw new IllegalArgumentException("Properties file path can not be null" + fullFile);
        }
        Properties p =null;
        try(InputStream inputStream =  DBPoolConnection.class.getClassLoader().getResourceAsStream(fullFile)) {
            p = new Properties();
            p.load(inputStream);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        }

        return p;
    }


}*/
